sudo ifconfig wlan0 10.10.10.1 netmask 255.255.255.0
sudo apt install network-manager
sudo systemctl start NetworkManager
sudo systemctl enable NetworkManager
sudo systemctl stop dhcpcd
sudo systemctl disable dhcpcd
查看连接
nmcli connection show
创建热点
nmcli connection add type wifi ifname `wlan0` con-name `openpi` autoconnect no ssid `openpi` mode ap
nmcli connection add type wifi ifname wlan0 con-name openpi autoconnect yes ipv4.method shared mode ap ssid openpi
sudo nmcli c add type wifi con-name openpi ifname wlan0 wifi.mode ap ipv4.method shared ssid <WIFI 名称>
# 开启 5G 频道(设为 2G 有时无法搜到,请勿修改)
$ sudo nmcli c mod openpi wifi.band a
# 设置 WIFI 密码(设为 WPA2 有的设备无法连接,请勿修改)
$ sudo nmcli c mod openpi wifi-sec.key-mgmt wpa-psk wifi-sec.psk <WIFI 密码>
设置 wifi 固定 ip
sudo nmcli c mod openpi ipv4.method manual ipv4.addresses 10.10.10.1/24
激活热点连接
nmcli connection up <connection-name>
nmcli connection up openpi
sudo vim /etc/NetworkManager/system-connections/hotspot.nmconnection
[connection]
id=hotspot
uuid=3edbab80-da08-43e5-9716-fc03f05fla1d
type=wifi
autoconnect=false
[wifi]
ssid=openpi
mode=ap
mac-address-blacklist=
[ipv4]
method=shared
[ipv6]
method=ignore
sudo nmcli connection up hotspot
nmcli device wifi list
nmcli device wifi connect <SSID> password <password>
nmcli connection add type bridge con-name br0 ifname br0
nmcli conn modify br0 ipv4.addresses '10.10.10.1/24'
nmcli conn modify br0 ipv4.gateway '10.10.10.1'
nmcli conn modify br0 ipv4.dns '8.8.8.8'
nmcli conn modify br0 ipv4.method manual
nmcli conn modify br0 ipv4.addresses '192.168.42.5/24'
nmcli conn modify br0 ipv4.gateway '192.168.42.1'
sudo nano /etc/NetworkManager/system-connections/bridge.nmconnection
[connection]
id=br0
uuid=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
type=bridge
interface-name=br0
sudo nmcli connection add type ethernet slave-type bridge con-name br-wlan0 ifname wlan0 master br0
sudo nmcli connection add type ethernet slave-type bridge con-name br-eth0 ifname eth0 master br0